package com.jiudengnile.dr.web.action;

import java.util.Date;

import wint.help.biz.result.Result;
import wint.lang.utils.DateUtil;
import wint.mvc.flow.FlowData;
import wint.mvc.template.Context;

import com.alibaba.fastjson.JSON;
import com.jiudengnile.dr.biz.ao.RecordDataAO;
import com.jiudengnile.dr.biz.common.DateTool;

public class MyTrace {
	
	private RecordDataAO recordDataAO;
	
	public void execute(FlowData flowData, Context context) {
		String uid = flowData.getParameters().getString("uid", "357710045052332-460008154635100");
		Date date = flowData.getParameters().getDate("yyyy-MM-dd", new Date());
		
		Date start = DateTool.the0clock(date);
		Date end = DateUtil.addDay(date, 1);
		
		Result result = recordDataAO.queryByDate(uid, start, end);
		if (result.isSuccess()) {
			context.put("result", "success");
			context.put("data", JSON.toJSON(result.getModels().get("data")) );
		} else {
			context.put("result", "failed");
			context.put("resultcode", result.getResultCode());
		}
	}

	public void setRecordDataAO(RecordDataAO recordDataAO) {
		this.recordDataAO = recordDataAO;
	}

}
